# Maintainer: Noel Kuntze <noel.kuntze@contauro.com>
pkgname=grommunio-admin-web
pkgdesc="Frontend for grommunio management"
pkgver=2.9.0
pkgrel=0
arch="noarch !riscv64"
url="http://www.grommunio.com"
license="AGPL-3.0-only"
options="!check" # No test suite
depends="grommunio-admin-api grommunio-admin-common"
makedepends="npm"

source="$pkgname-$pkgver.tar.gz::https://github.com/grommunio/admin-web/archive/refs/tags/$pkgver.tar.gz
	0001-makefile.patch
	config.json
	"

builddir="$srcdir/admin-web-$pkgver"

build() {
	make
}

package() {
	# webapp
	install -dm0755 "$pkgdir/usr/share/webapps/"
	cp -rp build "$pkgdir/usr/share/webapps/$pkgname"

	# license
	install -Dm644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

	# nginx conf
	sed -i "s@/usr/share/grommunio-admin-web@/usr/share/webapps/grommunio-admin-web@" conf/web.conf
	install -Dpm644 conf/web.conf "$pkgdir/usr/share/grommunio-admin-common/nginx.d/web.conf"

	# config.json
	install -Dm644 "$srcdir/config.json" "$pkgdir/etc/grommunio-admin-common/config.json"

	# npm gives ownership of ALL FILES to build user
	# https://bugs.archlinux.org/task/63396
	chown -R root:root "$pkgdir"
}

sha512sums="
c0dccb101de6acb6b54e1f839b62417a9d7cd45687d715e193e318b3d73dfd978afd80729cd2bfb1a2b7409985da721fa9aa5a7f22f65dbf920dd205a0d2bf64  grommunio-admin-web-2.9.0.tar.gz
5faa04f1f95cccdbb79a1e09f569a915794e236cb5738b25fd2e9f85b346875b6c1a8f20c3b53ccf823921eca0708a05da5c72f3b0971847ec34bfdbebf0f26e  0001-makefile.patch
c40b0722996b9d0449c3e11f2b56f59e1109b59253ffdf13422c21c56584924fe93a381250ce915656837c1c7799821bc6b6bcf463f867d6e529e59e3a899744  config.json
"
